window.addEventListener('load', function () {

    // 导航栏
    var nav = document.querySelector('.nav');
    // console.log(nav);

    var nav_lis = document.querySelectorAll('.nav>li');
    // console.log(nav_lis);
    // console.log(nav_lis.length);


    var items = document.querySelectorAll('.item')
    // console.log(items);

    for (var i = 0; i < nav_lis.length; i++) {
        // 给每个li设置索引

        nav_lis[i].setAttribute('index', i);

        nav_lis[i].addEventListener('mouseover', function () {
            var index = this.getAttribute('index');
            // console.log(index);
            for (var i = 0; i < items.length; i++) {
                items[i].style.display = 'none';
            }
            items[index].style.display = 'block';
        })

        items[i].addEventListener('mouseout', function () {
            this.style.display = 'none';
        })
    }


    var swiper = new Swiper('.swiper-container', {
        spaceBetween: 30,
        centeredSlides: true,
        autoplay: {
            delay: 2500,
            disableOnInteraction: false,
        },
        pagination: {
            el: '.swiper-pagination',
            clickable: true,
        },
        navigation: {
            nextEl: '.swiper-button-next',
            prevEl: '.swiper-button-prev',
        },
    });





})